<!DOCTYPE html>
<html>
<head>
    <title>预测测试</title>
</head>
<body>
    <h1>商品需求预测测试</h1>
    <form id="predictionForm">
        <label>开始日期: <input type="date" id="startDate" required></label><br>
        <label>结束日期: <input type="date" id="endDate" required></label><br>
        <label>商品编码: <input type="text" id="goodsCoding"></label><br>
        <button type="submit">开始预测</button>
    </form>
    <div id="result"></div>

    <script>
        document.getElementById('predictionForm').addEventListener('submit', async function(e) {
            e.preventDefault();
            
            const startDate = document.getElementById('startDate').value;
            const endDate = document.getElementById('endDate').value;
            const goodsCoding = document.getElementById('goodsCoding').value;
            
            const params = new URLSearchParams({
                startDate: startDate,
                endDate: endDate
            });
            
            if (goodsCoding) {
                params.append('goodsCoding', goodsCoding);
            }
            
            try {
                const response = await fetch(`/api/prediction/goods-prediction-simple?${params}`);
                const data = await response.json();
                document.getElementById('result').innerHTML = `<pre>${JSON.stringify(data, null, 2)}</pre>`;
            } catch (error) {
                document.getElementById('result').innerHTML = `<p>错误: ${error.message}</p>`;
            }
        });
        
        // 设置默认日期
        const today = new Date();
        const nextWeek = new Date(today);
        nextWeek.setDate(today.getDate() + 7);
        
        document.getElementById('startDate').value = today.toISOString().split('T')[0];
        document.getElementById('endDate').value = nextWeek.toISOString().split('T')[0];
    </script>
</body>
</html> 